package com.ellwood.common.core.base;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import java.io.Serial;
import java.io.Serializable;

/**
 * @ProjectName: Ellwood-framework-boot
 * @PackageName: com.ellwood.common.core.base
 * @ClassName: PageBase
 * @Description: // 查询公共参数以及分页基础信息
 * @Author: Ellwood
 * @Version: V1.0.0
 */
@Data
public class PageBase implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;


    /*@Schema(description ="当前页")
    private long current;

    @Schema(description ="每页条数")
    private long limit;

    @Schema(description ="总页数")
    private long totalPage;

    @Schema(description ="总条数")
    private long total;

    @Schema(description ="结果集")
    private List<T> rows;

    @Schema(description ="额外参数")
    private Object param;

    public PageBase(long current, long limit, long totalPage, long total, List<T> rows, Object param) {
        this.current = current;
        this.limit = limit;
        this.totalPage = totalPage;
        this.total = total;
        this.rows = rows;
        this.param = param;
    }*/

    @NotNull(message = "页码不能为空")
    @Min(value = 1, message = "页码最小值为 1")
    @Schema(description = "当前页码", requiredMode = Schema.RequiredMode.REQUIRED)
    Integer page;

    @NotNull(message = "每页条数不能为空")
    @Range(min = 1, max = 1000, message = "每页条数，取值范围 1-1000")
    @Schema(description = "每页条数", requiredMode = Schema.RequiredMode.REQUIRED)
    Integer limit;

    @Schema(description = "是否降序排序")
    String order;

    @Schema(description = "是否升序排序")
    boolean asc;

}
